home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / rcs / eprop.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  24.5 KB  |  825 lines

  1. head    1.2;
  2. access;
  3. symbols;
  4. locks
  5.     dlorre:1.2; strict;
  6. comment    @// @;
  7.  
  8.  
  9. 1.2
  10. date    97.07.14.04.19.32;    author dlorre;    state Exp;
  11. branches;
  12. next    1.1;
  13.  
  14. 1.1
  15. date    96.08.22.02.05.10;    author dlorre;    state Exp;
  16. branches;
  17. next    ;
  18.  
  19.  
  20. desc
  21. @Oui.lib -- Object User Interface
  22. Projet créé en 1994
  23. Auteur: Dominique Lorre
  24. @
  25.  
  26.  
  27. 1.2
  28. log
  29. @*** empty log message ***
  30. @
  31. text
  32. @// $Id$
  33.  
  34. #include <exec/lists.h>
  35. #include <graphics/gfxmacros.h>
  36. #include <intuition/classes.h>
  37. #include <intuition/classusr.h>
  38. #include <intuition/gadgetclass.h>
  39. #include <intuition/imageclass.h>
  40. #include <intuition/cghooks.h>
  41. #include <intuition/icclass.h>
  42. #include <utility/tagitem.h>
  43. #include <utility/hooks.h>
  44. #include <libraries/gadtools.h>
  45. #include <mydebug.h>
  46.  
  47. #include "gadgets/eprop.h"
  48. #include "gadgets/eclass.h"
  49.  
  50. #include "gadgetlist.h"
  51. #include "screen.h"
  52. #include "window.h"
  53.  
  54. #include <proto/graphics.h>
  55. #include <proto/intuition.h>
  56. #include <proto/utility.h>
  57. #include <clib/alib_protos.h>
  58. #include <compiler.h>
  59.  
  60. extern "C" STDARGS ULONG HookEntry() ;
  61.  
  62. static Class *BOOPSIeprop ;
  63. static int InitEProp(void) ;
  64. static void FreeEProp(void) ;
  65.  
  66. // ========================================================================
  67. // =============================  EPROP CLASS =============================
  68. // ========================================================================
  69.  
  70.  
  71. eprop::eprop(gadgetlist *gl,
  72.              void (window::*func)(gadget *, unsigned long, unsigned short),
  73.              long top,
  74.              long view,
  75.              long total,
  76.              long freedom,
  77.              char style) : gadget(gl, func)
  78. {
  79. short gleft, gtop, gwidth, gheight ;
  80.  
  81.     InitEProp() ;
  82.  
  83.     gleft = gl->ng->ng_LeftEdge ;
  84.     gtop = gl->ng->ng_TopEdge ;
  85.     gwidth = gl->ng->ng_Width ;
  86.     gheight = gl->ng->ng_Height ;
  87.  
  88.     if (style & BOTTOMPROP)
  89.         gtop = short(-gtop) ;
  90.     if (style & RIGHTPROP)
  91.         gleft = short(-gleft) ;
  92.     if (style & WIDTHPROP)
  93.         gwidth = short(-gwidth) ;
  94.     if (style & HEIGHTPROP)
  95.         gheight = short(-gheight) ;
  96.  
  97.     gad = gl->gad = (Gadget *)NewObject(BOOPSIeprop, NULL,
  98.             GA_Top,             gtop,
  99.             GA_Left,            gleft,
  100.             GA_Width,           gwidth,
  101.             GA_Height,          gheight,
  102.             GA_ID,              id,
  103.  
  104.             (style & BOTTOMPROP)?GA_BottomBorder:TAG_IGNORE,TRUE,
  105.             (style & RIGHTPROP)?GA_RightBorder:TAG_IGNORE,  TRUE,
  106.             (style & BOTTOMPROP)?GA_RelBottom:TAG_IGNORE,   TRUE,
  107.             (style & RIGHTPROP)?GA_RelRight:TAG_IGNORE,     TRUE,
  108.             (style & WIDTHPROP)?GA_RelWidth:TAG_IGNORE,     TRUE,
  109.             (style & HEIGHTPROP)?GA_RelHeight:TAG_IGNORE,   TRUE,
  110.  
  111.             GA_Immediate,       TRUE,
  112.             GA_FollowMouse,     TRUE,
  113.             GA_RelVerify,       TRUE,
  114.  
  115.             GA_Previous,        gl->gad,
  116.             GA_UserData,        PGA_Top,
  117.  
  118.             ICA_TARGET,         ICTARGET_IDCMP,
  119.  
  120.             PGA_Top,            top,
  121.             PGA_Total,          total,
  122.             PGA_Visible,        view,
  123.             PGA_Freedom,        freedom,
  124.             EGA_window,         gl->win,
  125.             TAG_END) ;
  126. }
  127.  
  128. eprop::~eprop()
  129. {
  130.     DisposeObject(gad) ;
  131.     FreeEProp() ;
  132. }
  133.  
  134.  
  135. void eprop::set(long top, long view, long total)
  136. {
  137.     SetGadgetAttrs(gad, w, NULL,
  138.         (top != -1)?PGA_Top:TAG_IGNORE,         top,
  139.         (total != -1)?PGA_Total:TAG_IGNORE,     total,
  140.         (view != -1)?PGA_Visible:TAG_IGNORE,    view,
  141.         TAG_END) ;
  142. }
  143.  
  144. void eprop::action(unsigned long classe, unsigned short code)
  145. {
  146.     if (classe != IDCMP_GADGETDOWN) {
  147.         gadget::action(classe, code) ;
  148.     }
  149. }
  150.  
  151. // ========================================================================
  152. // =============================== EPROP ==================================
  153. // ========================================================================
  154.  
  155. struct PropINST {
  156.  
  157.     long    Top ;
  158.     long    Total ;
  159.     long    Visible ;
  160.  
  161.     long    KLeft ;         // knob coords
  162.     long    KTop ;
  163.     long    KRight ;
  164.     long    KBottom ;
  165.  
  166.     long    PropLeft ;      // prop coords
  167.     long    PropTop ;
  168.     long    PropWidth ;
  169.     long    PropHeight ;
  170.  
  171.     long    IncLeft ;       // inc button coords
  172.     long    IncTop ;
  173.  
  174.     long    DecLeft ;       // dec button coords
  175.     long    DecTop ;
  176.  
  177.     long    ButWidth ;
  178.     long    ButHeight ;
  179.  
  180.     long    DTop ;
  181.     long    PTop ;          // previous top
  182.  
  183.     long    Flags ;
  184.  
  185.     BOOL    KnobHit ;
  186.     BOOL    DecHit ;
  187.     BOOL    IncHit ;
  188.  
  189.     BOOL    Drawable ;      // ok to redraw
  190.  
  191.     BOOL    RedrawAll ;
  192.     BOOL    RedrawInc ;
  193.     BOOL    RedrawDec ;
  194.     BOOL    RedrawBody ;
  195.     WORD    Direction ;     // Knob move=1, Inc=2, Dec=3
  196.  
  197.     window  *win ;
  198.  
  199.     struct  Image *arrowInc ;
  200.     struct  Image *arrowDec ;
  201. } ;
  202.  
  203. static ULONG STDARGS dispatchEProp(Class *cl, Object *o, Msg msg);
  204.  
  205. static ULONG   RenderEProp(Class *, Gadget *, gpRender *) ;
  206.  
  207. static void NotifyTop(Class *, Object *, ULONG, long, gpInput *) ;
  208.  
  209. static void    SetLims(PropINST *inst, Gadget *g, GadgetInfo *gi) ;
  210.  
  211. static void    CheckTop(PropINST *inst) ;
  212.  
  213.  
  214. static unsigned short ditherData[2] = {0x5555,0xAAAA};
  215. static int EPropCnt = 0 ;
  216.  
  217. int InitEProp(void)
  218. {
  219.     if (EPropCnt) {
  220.         EPropCnt++ ;
  221.     }
  222.     else if (!(BOOPSIeprop = MakeClass(NULL, (UBYTE *)"gadgetclass", NULL,
  223.         sizeof(PropINST), 0))) {
  224.         EPropCnt = 0 ;
  225.     }
  226.     else {
  227.         BOOPSIeprop->cl_Dispatcher.h_Entry = (HOOKFUNC)HookEntry ;
  228.         BOOPSIeprop->cl_Dispatcher.h_SubEntry = (HOOKFUNC)dispatchEProp;
  229.         BOOPSIeprop->cl_Dispatcher.h_Data = NULL ;
  230.         EPropCnt = 1 ;
  231.     }
  232.     return EPropCnt ;
  233. }
  234.  
  235. void FreeEProp(void)
  236. {
  237.     EPropCnt-- ;
  238.     if (!EPropCnt) {
  239.         FreeClass(BOOPSIeprop) ;
  240.     }
  241. }
  242.  
  243.  
  244. ULONG SAVEDS STDARGS dispatchEProp(Class *cl,
  245.                            Object *o,
  246.                            Msg msg)
  247. {
  248. PropINST *inst ;
  249. ULONG retval = FALSE ;
  250. Object *object ;
  251.  
  252.     GETA4 ;
  253.     switch (msg->MethodID) {
  254.     case OM_NEW:
  255.         if (object = (Object *)DoSuperMethodA(cl, o, msg)) {
  256.             Gadget *g = (Gadget *)object ;
  257.             screen *s ;
  258.  
  259.             inst = (PropINST *)INST_DATA(cl, object) ;
  260.             inst->KnobHit = inst->DecHit = inst->IncHit = FALSE ;
  261.             inst->Top = (long)GetTagData(PGA_Top, 0, ((opSet *)msg)->ops_AttrList ) ;
  262.             inst->Total = (long)GetTagData(PGA_Total, 0, ((opSet *)msg)->ops_AttrList) ;
  263.             inst->Visible = (long)GetTagData(PGA_Visible, 0, ((opSet *)msg)->ops_AttrList) ;
  264.             inst->Flags = (long)GetTagData(PGA_Freedom, LORIENT_VERT, ((opSet *)msg)->ops_AttrList) ;
  265.             inst->win = (window *)GetTagData(EGA_window, NULL, ((opSet *)msg)->ops_AttrList) ;
  266.             inst->RedrawAll = TRUE ;
  267.  
  268.  
  269.             if (g->Flags & GFLG_RELRIGHT)
  270.                 g->LeftEdge = (short)GetTagData(GA_Left, g->LeftEdge, ((opSet *)msg)->ops_AttrList) ;
  271.             if (g->Flags & GFLG_RELHEIGHT)
  272.                 g->Height = (short)GetTagData(GA_Height, g->Height, ((opSet *)msg)->ops_AttrList) ;
  273.             if (g->Flags & GFLG_RELWIDTH)
  274.                 g->Width = (short)GetTagData(GA_Width, g->Width, ((opSet *)msg)->ops_AttrList) ;
  275.             if (g->Flags & GFLG_RELBOTTOM)
  276.                 g->TopEdge = (short)GetTagData(GA_Top, g->TopEdge, ((opSet *)msg)->ops_AttrList) ;
  277.  
  278.             s = inst->win->ws ;
  279.  
  280.             inst->arrowInc = (Image *)NewObject(NULL, (UBYTE *)"sysiclass",
  281.                 IA_Left,        0,
  282.                 IA_Top,         0,
  283.                 SYSIA_DrawInfo, s->drawinfo,
  284.                 SYSIA_Which,    (inst->Flags & LORIENT_VERT)?DOWNIMAGE:RIGHTIMAGE,
  285.                 SYSIA_Size,     (s->scr->ViewPort.Modes & HIRES)?SYSISIZE_MEDRES:SYSISIZE_LOWRES,
  286.                 TAG_DONE) ;
  287.  
  288.             inst->arrowDec = (Image *)NewObject(NULL, (UBYTE *)"sysiclass",
  289.                 IA_Left,        0,
  290.                 IA_Top,         0,
  291.                 SYSIA_DrawInfo, s->drawinfo,
  292.                 SYSIA_Which,    (inst->Flags & LORIENT_VERT)?UPIMAGE:LEFTIMAGE,
  293.                 SYSIA_Size,     (s->scr->ViewPort.Modes & HIRES)?SYSISIZE_MEDRES:SYSISIZE_LOWRES,
  294.                 TAG_DONE) ;
  295.  
  296.             inst->ButWidth = inst->arrowInc->Width ;
  297.             inst->ButHeight = inst->arrowInc->Height ;
  298.  
  299.             retval = (ULONG)object ;
  300.         }
  301.  
  302.         break ;
  303.     case OM_DISPOSE:
  304.         inst = (PropINST *)INST_DATA(cl, o) ;
  305.         DisposeObject(inst->arrowInc) ;
  306.         DisposeObject(inst->arrowDec) ;
  307.         retval = DoSuperMethodA(cl, o, msg) ;
  308.         break ;
  309.     case GM_HITTEST:
  310.         retval = DoSuperMethodA(cl, o, msg) ;
  311.         break ;
  312.     case GM_GOACTIVE:
  313.         {
  314.         gpInput *gpi = (gpInput *)msg ;
  315.         WORD mx = gpi->gpi_Mouse.X ;
  316.         WORD my = gpi->gpi_Mouse.Y ;
  317.             inst = (PropINST *)INST_DATA(cl, o) ;
  318.             if (gpi->gpi_IEvent) {
  319.                 ((Gadget *)o)->Flags |= GFLG_SELECTED ;
  320.                 inst->RedrawAll = FALSE ;
  321.                 if (((mx + inst->PropLeft) >= inst->KLeft) &&
  322.                     ((mx + inst->PropLeft) <= inst->KRight) &&
  323.                     ((my + inst->PropTop) >= inst->KTop) &&
  324.                     ((my + inst->PropTop) <= inst->KBottom)) {
  325.                         inst->KnobHit = TRUE ;
  326.                         inst->Direction = 1 ;
  327.                         if (inst->Flags & LORIENT_VERT) {
  328.                             inst->DTop = (my * inst->Total) / inst->PropHeight - inst->Top ;
  329.                         }
  330.                         else {
  331.                             inst->DTop = (mx * inst->Total) / inst->PropWidth - inst->Top ;
  332.                         }
  333.                 }
  334.                 else if ((inst->Flags & LORIENT_VERT) &&
  335.                         ((my + inst->PropTop) >= inst->IncTop) &&
  336.                         ((my + inst->PropTop) <= (inst->IncTop+inst->ButHeight))) {
  337.                         inst->IncHit = TRUE ;
  338.                         inst->RedrawInc = TRUE ;
  339.                         inst->Direction = 2 ;
  340.                 }
  341.                 else if ((inst->Flags & LORIENT_VERT) &&
  342.                         ((my + inst->PropTop) >= inst->DecTop) &&
  343.                         ((my + inst->PropTop) <= (inst->DecTop+inst->ButHeight))) {
  344.                         inst->DecHit = TRUE ;
  345.                         inst->RedrawDec = TRUE ;
  346.                         inst->Direction = 3 ;
  347.                 }
  348.                 else if ((inst->Flags & LORIENT_HORIZ) &&
  349.                         ((mx + inst->PropLeft) >= inst->IncLeft) &&
  350.                         ((mx + inst->PropLeft) <= (inst->IncLeft+inst->ButWidth))) {
  351.                         inst->IncHit = TRUE ;
  352.                         inst->RedrawInc = TRUE ;
  353.                         inst->Direction = 2 ;
  354.                 }
  355.                 else if ((inst->Flags & LORIENT_HORIZ) &&
  356.                         ((mx + inst->PropLeft) >= inst->DecLeft) &&
  357.                         ((mx + inst->PropLeft) <= (inst->DecLeft+inst->ButWidth))) {
  358.                         inst->DecHit = TRUE ;
  359.                         inst->RedrawDec = TRUE ;
  360.                         inst->Direction = 3 ;
  361.                 }
  362.                 else {
  363.                     inst->Direction = 0 ;
  364.                     if (inst->Flags & LORIENT_VERT)
  365.                         if ((my + inst->PropTop)<= inst->KTop)
  366.                             inst->Top -= inst->Visible ;
  367.                         else
  368.                             inst->Top += inst->Visible ;
  369.                     else
  370.                         if ((mx + inst->PropLeft)<= inst->KLeft)
  371.                             inst->Top -= inst->Visible ;
  372.                         else
  373.                             inst->Top += inst->Visible ;
  374.  
  375.                     CheckTop(inst) ;
  376.  
  377.                 }
  378.                 NotifyTop(cl, o, OPUF_INTERIM, inst->Top, gpi) ;
  379.                 retval = GMR_MEACTIVE ;
  380.                 *(gpi->gpi_Termination) = inst->Top ;
  381.                 RenderEProp(cl, (Gadget *)o, (gpRender *)msg) ;
  382.             }
  383.             else
  384.                 retval = GMR_NOREUSE ;
  385.         }
  386.         break ;
  387.  
  388.     case GM_RENDER:
  389.         retval = RenderEProp(cl, (Gadget *)o, (gpRender *)msg) ;
  390.         break ;
  391.     case GM_HANDLEINPUT:
  392.         {
  393.             gpInput *gpi = (gpInput *)msg ;
  394.             InputEvent *ie = gpi->gpi_IEvent ;
  395.             WORD mx = gpi->gpi_Mouse.X ;
  396.             WORD my = gpi->gpi_Mouse.Y ;
  397.  
  398.             inst = (PropINST *)INST_DATA(cl, o) ;
  399.             inst->PTop = inst->Top ;
  400.             retval = GMR_MEACTIVE  ;
  401.  
  402.             if (ie->ie_Class == IECLASS_RAWMOUSE) {
  403.                 switch (ie->ie_Code) {
  404.                     case SELECTUP:
  405.                         *(gpi->gpi_Termination) = inst->Top ;
  406.                         retval = GMR_NOREUSE | GMR_VERIFY ;
  407.                         break ;
  408.                     case MENUDOWN:
  409.                         retval = GMR_REUSE ;
  410.                         NotifyTop(cl, o, 0, inst->Top, (gpInput *)msg) ;
  411.                         break ;
  412.                     default:
  413.                         retval = GMR_MEACTIVE ;
  414.                 }
  415.             }
  416.             else if ((ie->ie_Class == IECLASS_TIMER ||
  417.                 ie->ie_Class == IECLASS_POINTERPOS)
  418.                 && inst->Direction) {
  419.                 switch (inst->Direction) {
  420.                 case 1:
  421.                     if (inst->Flags & LORIENT_VERT) {
  422.                         inst->Top = (my * inst->Total) / inst->PropHeight - inst->DTop ;
  423.                     }
  424.                     else {
  425.                         inst->Top = (mx * inst->Total) / inst->PropWidth - inst->DTop ;
  426.                     }
  427.                     break ;
  428.                 case 2:
  429.                     inst->Top++ ;
  430.                     break ;
  431.                 case 3:
  432.                     inst->Top-- ;
  433.                     break ;
  434.                 }
  435.                 CheckTop(inst) ;
  436.                 if (inst->PTop != inst->Top) {
  437.                     RenderEProp(cl, (Gadget *)o, (gpRender *)msg) ;
  438.                     inst->RedrawInc = inst->RedrawDec = FALSE ;
  439.                     NotifyTop(cl, o, OPUF_INTERIM, inst->Top, gpi) ;
  440.                 }
  441.             }
  442.         }
  443.         break ;
  444.     case GM_GOINACTIVE:
  445.         ((Gadget *)o)-> Flags &= ~GFLG_SELECTED ;
  446.         inst = (PropINST *)INST_DATA(cl, o) ;
  447.         inst->KnobHit = inst->IncHit = inst->DecHit = FALSE ;
  448.         inst->RedrawAll = TRUE ;
  449.         inst->RedrawInc = inst->RedrawDec = FALSE ;
  450.         inst->RedrawBody = FALSE ;
  451.         RenderEProp(cl, (Gadget *)o, (gpRender *)msg) ;
  452.         break ;
  453.     case OM_GET:
  454.         inst = (PropINST *)INST_DATA(cl, o) ;
  455.         switch (((opGet *)msg)->opg_AttrID) {
  456.         case PGA_Top:
  457.             retval = inst->Top ;
  458.             break ;
  459.         case PGA_Total:
  460.             retval = inst->Total ;
  461.             break ;
  462.         case PGA_Visible:
  463.             retval = inst->Visible ;
  464.             break ;
  465.         default:
  466.             retval = DoSuperMethodA(cl, o, msg) ;
  467.         }
  468.         break ;
  469.     case OM_SET:
  470.         if ( FindTagItem(PGA_Top, ((opSet *)msg)->ops_AttrList) ||
  471.             FindTagItem(PGA_Total, ((opSet *)msg)->ops_AttrList) ||
  472.             FindTagItem(PGA_Visible, ((opSet *)msg)->ops_AttrList) ) {
  473.             RastPort *rp ;
  474.             Gadget *g  = (Gadget *)o ;
  475.  
  476.             inst = (PropINST *)INST_DATA(cl, o) ;
  477.             inst->Top = (long)GetTagData(PGA_Top, inst->Top, ((opSet *)msg)->ops_AttrList) ;
  478.             inst->Total = (long)GetTagData(PGA_Total, inst->Total, ((opSet *)msg)->ops_AttrList) ;
  479.             inst->Visible = (long)GetTagData(PGA_Visible, inst->Visible, ((opSet *)msg)->ops_AttrList) ;
  480.  
  481.             CheckTop(inst) ;
  482.  
  483.             SetLims(inst, g, ((opSet *)msg)->ops_GInfo) ;
  484.             inst->RedrawAll = FALSE ;
  485.             inst->RedrawBody = TRUE ;
  486.  
  487.             if (rp = ObtainGIRPort( ((opSet *)msg)->ops_GInfo) ) {
  488.  
  489.                 DoMethod(o, GM_RENDER, ((opSet *)msg)->ops_GInfo, rp, GREDRAW_REDRAW) ;
  490.                 ReleaseGIRPort(rp) ;
  491.             }
  492.             inst->RedrawBody = FALSE ;
  493.             inst->RedrawAll = TRUE ;
  494.         }
  495.         else
  496.             retval = DoSuperMethodA(cl, o, msg) ;
  497.         break ;
  498.     default :
  499.         retval = DoSuperMethodA(cl, o, msg) ;
  500.         break ;
  501.     }
  502.     return retval ;
  503. }
  504.  
  505. void SAVEDS CheckTop(PropINST *inst)
  506. {
  507.     GETA4 ;
  508.     if (inst->Top < 0)
  509.         inst->Top = 0 ;
  510.     else if (inst->Visible <= inst->Total) {
  511.         if ((inst->Top + inst->Visible) > (inst->Total+1)) {
  512.             inst->Top = inst->Total - inst->Visible + 1 ;
  513.         }
  514.     }
  515.     else if (inst->Visible > inst->Total)
  516.         inst->Top = 0 ;
  517. //    else if (inst->Top >= inst->Total)
  518. //        inst->Top = inst->Total - 1 ;
  519. }
  520.  
  521. void SAVEDS NotifyTop(Class *cl, Object *o, ULONG flags, long top, gpInput *gpi)
  522. {
  523. static TagItem tt[3] ;
  524.  
  525.     GETA4 ;
  526.     tt[0].ti_Tag = PGA_Top ;
  527.     tt[0].ti_Data = top  ;
  528.  
  529.     tt[1].ti_Tag = GA_ID ;
  530.     tt[1].ti_Data = ((Gadget *)o)->GadgetID ;
  531.  
  532.     tt[2].ti_Tag = TAG_DONE ;
  533.  
  534.     DoSuperMethod(cl, o, OM_NOTIFY, tt, gpi->gpi_GInfo, flags) ;
  535. }
  536.  
  537. ULONG SAVEDS RenderEProp(Class *cl, Gadget *g, gpRender *msg)
  538. {
  539. RastPort *rp ;
  540. ULONG retval = TRUE ;
  541. UWORD *pens = msg->gpr_GInfo->gi_DrInfo->dri_Pens ;
  542. PropINST *inst = (PropINST *)INST_DATA(cl, (Object *)g) ;
  543.  
  544.     GETA4 ;
  545.     // Obtention du rastport
  546.  
  547.     if (msg->MethodID == GM_RENDER)
  548.         rp = msg->gpr_RPort ;
  549.     else
  550.         rp = ObtainGIRPort(msg->gpr_GInfo) ;
  551.  
  552.     if (rp) {
  553.         UWORD shine, shadow ;
  554.         long  flag ;
  555.  
  556.         SetAPen(rp, pens[SHADOWPEN]) ;
  557.         SetBPen(rp, 0) ;
  558.         SetDrMd(rp, JAM2) ;
  559.         SetAfPt(rp, ditherData, 1) ;
  560.  
  561.         // Redessiner tout ou bien tout sauf partie +/- ?
  562.  
  563.         if (inst->RedrawAll || inst->RedrawBody) {
  564.             SetLims(inst, g, msg->gpr_GInfo) ;  // Calcul des limites
  565.  
  566.             if (!inst->Drawable) {
  567.                 retval = FALSE ;
  568.                 goto out ;
  569.             }
  570.             RectFill(rp,            // Effacer tout le corps du Gadget
  571.                 inst->PropLeft,
  572.                 inst->PropTop,
  573.                 inst->PropLeft+inst->PropWidth-1,
  574.                 inst->PropTop+inst->PropHeight-1) ;
  575.         }
  576.         else {                      // Effacer le knob
  577.             RectFill(rp,
  578.                 inst->KLeft,
  579.                 inst->KTop,
  580.                 inst->KRight,
  581.                 inst->KBottom) ;
  582.             SetLims(inst, g, msg->gpr_GInfo) ;  // Calcul des limites
  583.             if (!inst->Drawable) {
  584.                 retval = FALSE ;
  585.                 goto out ;
  586.             }
  587.         }
  588.         SetAfPt(rp, NULL, 0 ) ; // Fin du tramage
  589.  
  590.         // Choix des pinceaux suivant activation du Knob
  591.         if (inst->KnobHit) {
  592.             shine = pens[SHADOWPEN] ;
  593.             shadow = pens[SHINEPEN] ;
  594.         }
  595.         else {
  596.             shine = pens[SHINEPEN] ;
  597.             shadow = pens[SHADOWPEN] ;
  598.         }
  599.  
  600.         SetAPen(rp, pens[HIGHLIGHTTEXTPEN]) ;    // Activer le tramage
  601.         SetAfPt(rp, ditherData, 1) ;
  602.  
  603.         RectFill(rp, inst->KLeft,     // Dessiner le Knob
  604.                      inst->KTop,
  605.                      inst->KRight,
  606.                      inst->KBottom) ;
  607.  
  608.         SetAfPt(rp, NULL, 0 ) ;         // Fin du tramage
  609.  
  610.         // Contours du knob
  611.  
  612.         SetAPen(rp, shadow) ;
  613.         Move(rp, inst->KLeft+1, inst->KBottom) ;
  614.         Draw(rp, inst->KRight, inst->KBottom) ;
  615.         Draw(rp, inst->KRight, inst->KTop+1) ;
  616.  
  617.         SetAPen(rp, shine) ;
  618.         Move(rp, inst->KLeft, inst->KBottom-1) ;
  619.         Draw(rp, inst->KLeft, inst->KTop) ;
  620.         Draw(rp, inst->KRight-1, inst->KTop) ;
  621.  
  622.         if (msg->gpr_GInfo->gi_Window->Flags & WFLG_WINDOWACTIVE) {
  623.             flag = 0 ;
  624.         }
  625.         else {
  626.             flag = IDS_INACTIVENORMAL ;
  627.         }
  628.  
  629.         // Partie [-]
  630.  
  631.         if (inst->RedrawDec || inst->RedrawAll) {
  632.             DrawImageState( rp, inst->arrowDec,
  633.                 inst->DecLeft, inst->DecTop,
  634.                 inst->DecHit?flag+IDS_SELECTED:flag+IDS_NORMAL, inst->win->ws->drawinfo);
  635.         }
  636.  
  637.         // Partie [+]
  638.  
  639.         if (inst->RedrawInc || inst->RedrawAll) {
  640.             DrawImageState( rp, inst->arrowInc,
  641.                 inst->IncLeft, inst->IncTop,
  642.                 inst->IncHit?flag+IDS_SELECTED:flag+IDS_NORMAL, inst->win->ws->drawinfo);
  643.  
  644.         }
  645.  
  646. out:
  647.         if (msg->MethodID != GM_RENDER) // Restitution du RastPort
  648.             ReleaseGIRPort(rp) ;
  649.     }
  650.     else
  651.         retval = FALSE ;
  652.     return retval ;
  653. }
  654.  
  655.  
  656. void SAVEDS SetLims(PropINST *inst, Gadget *g, GadgetInfo *gi)
  657. {
  658. long GLeft, GTop, GWidth, GHeight ;
  659. long KWidth, KHeight ;
  660.  
  661.     GETA4 ;
  662.     GLeft = g->LeftEdge ;
  663.     GTop = g->TopEdge ;
  664.     GWidth = g->Width  ;
  665.     GHeight = g->Height ;
  666.  
  667.     if (g->Flags & GFLG_RELRIGHT) {
  668.         GLeft = gi->gi_Window->Width ;
  669.         GLeft += g->LeftEdge ;
  670.     }
  671.  
  672.     if (g->Flags & GFLG_RELHEIGHT) {
  673.         GHeight = gi->gi_Window->Height ;
  674.         GHeight += g->Height ;
  675.     }
  676.  
  677.     if (g->Flags & GFLG_RELBOTTOM) {
  678.         GTop = gi->gi_Window->Height ;
  679.         GTop += g->TopEdge ;
  680.     }
  681.  
  682.     if (g->Flags & GFLG_RELWIDTH) {
  683.         GWidth = gi->gi_Window->Width ;
  684.         GWidth += g->Width ;
  685.     }
  686.  
  687.     if (g->Activation & GACT_BOTTOMBORDER) {
  688.         GTop-- ;
  689.     }
  690.     if (g->Activation & GACT_RIGHTBORDER) {
  691.         GLeft-- ;
  692.     }
  693.  
  694.     if (inst->Flags & LORIENT_VERT)
  695.         inst->Drawable = short((GWidth > 4) && (GHeight > inst->ButHeight*2+8) &&
  696.         (gi->gi_Window->Width > (GWidth+gi->gi_Window->BorderLeft))) ;
  697.     else
  698.         inst->Drawable = short((GWidth > inst->ButWidth*2+8) && (GHeight > 4) &&
  699.         (gi->gi_Window->Height > (GHeight+gi->gi_Window->BorderTop))) ;
  700.  
  701.     inst->PropLeft = GLeft  ;
  702.     inst->PropTop = GTop ;
  703.  
  704.     if (inst->Flags & LORIENT_VERT) {
  705.         inst->PropLeft += 2 ;
  706.         inst->PropWidth = GWidth  - 4 ;
  707.         inst->PropHeight = GHeight - inst->ButHeight*2 ;
  708.         inst->DecLeft = inst->IncLeft = GLeft ;
  709.         inst->DecTop = inst->PropTop + inst->PropHeight ;
  710.         inst->IncTop = inst->DecTop + inst->ButHeight ;
  711.     }
  712.     else {
  713.         inst->PropTop += 2 ;
  714.         inst->PropHeight = GHeight - 4 ;
  715.         inst->PropWidth = GWidth - inst->ButWidth*2 ;
  716.         inst->DecTop = inst->IncTop = GTop ;
  717.         inst->DecLeft = inst->PropLeft + inst->PropWidth ;
  718.         inst->IncLeft = inst->DecLeft + inst->ButWidth ;
  719.     }
  720.  
  721.     inst->KLeft = inst->PropLeft ;
  722.     inst->KTop = inst->PropTop ;
  723.     KWidth = inst->PropWidth  ;
  724.     KHeight = inst->PropHeight   ;
  725.  
  726.     if ((inst->Flags & LORIENT_HORIZ) && (inst->Total >= inst->Visible)) {
  727.         inst->KLeft += (inst->PropWidth * inst->Top) / (inst->Total+1) ;
  728.         KWidth *= inst->Visible ;
  729.         KWidth /= (inst->Total+1) ;
  730.         if (KWidth < 8) {
  731.             KWidth = 8 ;
  732.             if (inst->KLeft > (inst->DecLeft - 8))
  733.                 inst->KLeft = inst->DecLeft - 8 ;
  734.         }
  735.     }
  736.     else if ((inst->Flags & LORIENT_VERT) && (inst->Total >= inst->Visible)) {
  737.         inst->KTop += (inst->PropHeight * inst->Top) / (inst->Total+1) ;
  738.         KHeight *= inst->Visible ;
  739.         KHeight /= (inst->Total+1) ;
  740.         if (KHeight < 8) {
  741.             KHeight = 8 ;
  742.             if (inst->KTop > (inst->DecTop - 8))
  743.                 inst->KTop = inst->DecTop - 8 ;
  744.         }
  745.     }
  746.  
  747.     inst->KRight = inst->KLeft + KWidth -1;
  748.     inst->KBottom = inst->KTop + KHeight -1;
  749. }
  750. @
  751.  
  752.  
  753. 1.1
  754. log
  755. @Initial revision
  756. @
  757. text
  758. @d1 2
  759. d14 1
  760. d23 5
  761. a27 2
  762. #include <cxxproto/graphics.h>
  763. #include <cxxproto/intuition.h>
  764. d29 1
  765. a29 14
  766. extern "C"
  767. {
  768. extern struct Library *UtilityBase ;
  769. struct TagItem *FindTagItem( Tag tagVal, struct TagItem *tagList );
  770. ULONG GetTagData( Tag tagValue, unsigned long defaultVal,
  771.         struct TagItem *tagList );
  772. #include <pragmas/utility_pragmas.h>
  773.  
  774. ULONG DoMethod( Object *obj, unsigned long MethodID, ... );
  775. ULONG DoSuperMethodA( struct IClass *cl, Object *obj, Msg message );
  776. ULONG DoSuperMethod( struct IClass *cl, Object *obj, unsigned long MethodID,
  777.         ... );
  778. void kprintf(STRPTR format, ...) ;
  779. }
  780. d172 1
  781. a172 2
  782. static ULONG __asm dispatchEProp(register __a0 Class *cl,
  783.     register __a2 Object *o, register __a1 Msg msg);
  784. d191 1
  785. a191 1
  786.     else if (!(BOOPSIeprop = MakeClass(NULL, "gadgetclass", NULL,
  787. d196 3
  788. a198 1
  789.         BOOPSIeprop->cl_Dispatcher.h_Entry = (HOOKFUNC)dispatchEProp;
  790. d213 3
  791. a215 3
  792. ULONG __saveds __asm dispatchEProp(register __a0 Class *cl,
  793.                                    register __a2 Object *o,
  794.                                    register __a1 Msg msg)
  795. d220 2
  796. d249 1
  797. a249 1
  798.             inst->arrowInc = (Image *)NewObject(NULL, "sysiclass",
  799. d254 1
  800. a254 1
  801.                 SYSIA_Size,     (s->screen->ViewPort.Modes & HIRES)?SYSISIZE_MEDRES:SYSISIZE_LOWRES,
  802. d257 1
  803. a257 1
  804.             inst->arrowDec = (Image *)NewObject(NULL, "sysiclass",
  805. d262 1
  806. a262 1
  807.                 SYSIA_Size,     (s->screen->ViewPort.Modes & HIRES)?SYSISIZE_MEDRES:SYSISIZE_LOWRES,
  808. d474 1
  809. a474 1
  810. void __saveds CheckTop(PropINST *inst)
  811. d476 1
  812. d490 1
  813. a490 1
  814. void __saveds NotifyTop(Class *cl, Object *o, ULONG flags, long top, gpInput *gpi)
  815. d494 1
  816. d506 1
  817. a506 1
  818. ULONG __saveds RenderEProp(Class *cl, Gadget *g, gpRender *msg)
  819. d513 1
  820. d625 1
  821. a625 1
  822. void __saveds SetLims(PropINST *inst, Gadget *g, GadgetInfo *gi)
  823. d630 1
  824. @
  825.